﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Stock_VoucherOut
    {
        public long ID { get; set; }
        [Description("Số phiếu")]
        public string VoucherOutNo { get; set; }
        [Description("Ngày lập phiếu")]
        public DateTime VoucherDate { get; set; }
        public long WarehouseID { get; set; }
        public long Output_MethodID { get; set; }
        [Description("Số chứng từ")]
        public string BillNo { get; set; }
        public long Payment_MethodID { get; set; }
        public long EmployeeID { get; set; }
        [Description("Ghi chú")]
        public string Note { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDate { get; set; }
        public long LastModifiedBy { get; set; }
        public DateTime LastModifiedDate { get; set; }
        [Description("Thành tiền")]
        public decimal Amount { get; set; }
        [Description("Thuế VAT")]
        public bool VAT { get; set; }
        [Description("Tổng cộng")]
        public decimal TotalAmount { get; set; }
        public long PersonID { get; set; }
        public string CustomerName { get; set; }
        public long PlaceID { get; set; }
        public string TypeOfOut { get; set; }
        public bool Active { get; set; }
        public bool IsDelete { get; set; }
        [Description("Kho")]
        public string StockNameExt { get; set; }
        [Description("Phương thức xuất")]
        public string Output_MethodNameExt { get; set; }
        [Description("Phương thức thanh toán")]
        public string PaymentMethodNameExt { get; set; }
        [Description("Người lập")]
        public string EmployeeNameExt { get; set; }
         
        public Stock_VoucherOut()
        {       
                            VoucherOutNo ="";   
                            BillNo ="";   
                            Note ="";   
        }
        
       static Stock_VoucherOut DynamicCast<T>(object row_data, object row_header) where T : Stock_VoucherOut
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Stock_VoucherOut ret = new Stock_VoucherOut();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                   case "ID":
                       ret.ID = ConvertObject.ToInt(dt[column]);
                       break;
                   case "VoucherOutNo":
                       ret.VoucherOutNo = ConvertObject.ToString(dt[column]);
                       break;
                   case "VoucherDate":
                       ret.VoucherDate = ConvertObject.ToDateTime(dt[column]);
                       break;
                   case "WarehouseID":
                       ret.WarehouseID = ConvertObject.ToInt(dt[column]);
                       break;
                   case "Output_MethodID":
                       ret.Output_MethodID = ConvertObject.ToInt(dt[column]);
                       break;
                   case "BillNo":
                       ret.BillNo = ConvertObject.ToString(dt[column]);
                       break;
                   case "Payment_MethodID":
                       ret.Payment_MethodID = ConvertObject.ToInt(dt[column]);
                       break;
                   case "EmployeeID":
                       ret.EmployeeID = ConvertObject.ToInt(dt[column]);
                       break;
                   case "Note":
                       ret.Note = ConvertObject.ToString(dt[column]);
                       break;
                   case "Amount":
                       ret.Amount = ConvertObject.ToDecimal(dt[column]);
                       break;
                   case "VAT":
                       ret.VAT = ConvertObject.ToBool(dt[column]);
                       break;
                   case "TotalAmount":
                       ret.TotalAmount = ConvertObject.ToDecimal(dt[column]);
                       break;
                   case "PersonID":
                       ret.PersonID = ConvertObject.ToInt(dt[column]);
                       break;
                   case "PlaceID":
                       ret.PlaceID = ConvertObject.ToInt(dt[column]);
                       break;
                   case "CustomerName":
                       ret.CustomerName = ConvertObject.ToString(dt[column]);
                       break;
                   case "TypeOfOut":
                       ret.TypeOfOut = ConvertObject.ToString(dt[column]);
                       break;
                   case "Active":
                       ret.Active = ConvertObject.ToBool(dt[column]);
                       break;
                   case "IsDelete":
                       ret.IsDelete = ConvertObject.ToBool(dt[column]);
                       break;
                   case "CreatedBy":
                       ret.CreatedBy = ConvertObject.ToInt(dt[column]);
                       break;
                   case "CreatedDate":
                       ret.CreatedDate = ConvertObject.ToDateTime(dt[column]);
                       break;
                   case "LastModifiedBy":
                       ret.LastModifiedBy = ConvertObject.ToInt(dt[column]);
                       break;
                   case "StockName":
                       ret.StockNameExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Output_MethodName":
                       ret.Output_MethodNameExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "PaymentMethodName":
                       ret.PaymentMethodNameExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "EmployeeName":
                       ret.EmployeeNameExt = ConvertObject.ToString(dt[column]);
                       break;
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
